package org.darkforest.admin.controller;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.darkforest.common.logger.Logger;
import org.darkforest.common.services.EmployeeService;
import org.darkforest.common.services.SettingService;
import org.darkforest.common.util.DateUtil;
import org.darkforest.common.util.Page;
import org.darkforest.dao.mapper.*;
import org.darkforest.enums.SettingNameEnum;
import org.darkforest.model.*;
import org.darkforest.ucenter.auth.AuthPassport;
import org.darkforest.ucenter.service.MemberService;
import org.darkforest.ucenter.service.MessageService;
import org.darkforest.vo.MemberBase;
import org.darkforest.vo.MemberSearchBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.util.Enumeration;
import java.util.List;

/**
 * Created by valentina on 15/5/11.
 * 会员控制类
 */
@Controller
@RequestMapping("member")
public class MemberController {

    @Autowired
    @Qualifier("memberServiceImpl")
    private MemberService memberService;

    @Autowired
    private EmployeeService employeeService;

    @Autowired
    private PointsLogMapper pointsLogMapper;

    @Autowired
    private PdRechargeMapper pdRechargeMapper;

    @Autowired
    private PdCashMapper pdCashMapper;

    @Autowired
    private PdLogMapper pdLogMapper;

    @Autowired
    private MemberMapper memberMapper;

    @Autowired
    private SettingService settingService;

    @Autowired
    private MessageService messageService;

    @Autowired
    private EnumParamMapper enumParamMapper;

    @AuthPassport
    @RequestMapping("positSetting")
    public ModelAndView positSetting(Integer page,Integer mid, String mname,String query_start_date,String query_end_date,String paystate_search){
        ModelAndView modelAndView = new ModelAndView("member/posit/posit_setting");
        PdRechargeSearchBean pdRecharge = new PdRechargeSearchBean();
        pdRecharge.setStart(page == null ? 1 : page);
        pdRecharge.setPageSize(Page.DEFAULT_PAGE_SIZE);
        pdRecharge.setMemberId(mid);
        pdRecharge.setMname(mname);
        pdRecharge.setQueryStartDate(query_start_date);
        pdRecharge.setQueryEndDate(query_end_date);
        pdRecharge.setPayState(paystate_search);
        List<PdRechargeVo> pdRecharges = pdRechargeMapper.selectByMember(pdRecharge);
        pdRecharge.setResultList(pdRecharges);
        modelAndView.addObject("modelPage", pdRecharge);
        return modelAndView;
    }

    @RequestMapping("positSetting/positView")
    public ModelAndView positView(String id){
        ModelAndView modelAndView = new ModelAndView("member/posit/posit_view");
        if(org.apache.commons.lang.StringUtils.isNotEmpty(id)){
            PdRecharge pdRecharge = pdRechargeMapper.selectByPrimaryKey(Integer.parseInt(id));
            modelAndView.addObject("pdRecharge", pdRecharge);
        }

        return modelAndView;
    }

    @RequestMapping("positSetting/positToEdit")
    public ModelAndView positToEdit(String id){
        ModelAndView modelAndView = new ModelAndView("member/posit/posit_edit");
        PdRecharge pdRecharge = new PdRecharge();
        if(org.apache.commons.lang.StringUtils.isNotEmpty(id)){
            pdRecharge = pdRechargeMapper.selectByPrimaryKey(Integer.parseInt(id));
        }
        modelAndView.addObject("pdRecharge", pdRecharge);
        return modelAndView;
    }
    @RequestMapping("positSetting/positDoEdit")
    public String positDoEdit(PdRecharge pdRecharge,Integer operatetype,String payment_time,HttpServletRequest request){
        MemberBase memberBase = (MemberBase)request.getSession().getAttribute("memInfo");
        String path = "redirect:/member/positSetting";
        pdRecharge.setPdrPaymentState("1");
        pdRecharge.setPdrPaymentTime(DateUtil.toUnixTimeStampByDate(payment_time));
        pdRecharge.setPdrSn(pdRecharge.getPdrSn()==null?0L:pdRecharge.getPdrSn());
        //如果是减少的情况，将
        if(operatetype!=null && operatetype==2){
            pdRecharge.setPdrAmount(pdRecharge.getPdrAmount().negate());
        }
        //管理员手工修改余额的情况
        if(pdRecharge==null || pdRecharge.getPdrId()==null){
            pdRecharge.setPdrAddTime(DateUtil.toUnixTimeStampByDate(payment_time));
            pdRechargeMapper.insert(pdRecharge);
            path = "redirect:/member/positSetting/logList";
        }else{
            //对已提交的充值申请进行更新操作
            pdRechargeMapper.updateByPrimaryKeySelective(pdRecharge);
        }

        PdLog pdLog = new PdLog();
        pdLog.setLgMemberId(pdRecharge.getPdrMemberId());
        pdLog.setLgMemberName(pdRecharge.getPdrMemberName());
        pdLog.setLgAdminName(memberBase.getUserName());
        pdLog.setLgType("recharge");
        pdLog.setLgAvAmount(pdRecharge.getPdrAmount());
        pdLog.setLgAddTime(Integer.parseInt(DateUtil.unixTimeStamp()));
        pdLog.setLgDesc("");
        pdLogMapper.insertSelective(pdLog);
        Member mb = memberMapper.getMemberById(pdRecharge.getPdrMemberId());
        if(mb.getAvailablePredeposit()!=null){
            mb.setAvailablePredeposit(mb.getAvailablePredeposit().add(pdRecharge.getPdrAmount()));
        }else{
            mb.setAvailablePredeposit(pdRecharge.getPdrAmount());
        }

        memberMapper.updateMemberBaseInfo(mb);
        return  path;
    }

    @RequestMapping("positDel")
    public String positDel(Integer id){
        pdRechargeMapper.deleteByPrimaryKey(id);
        return  "redirect:/member/positSetting";
    }

    @RequestMapping("positSetting/cashList")
    public ModelAndView cashList(Integer page, String mname,String pdc_bank_user,String stime,String etime,String paystate_search, HttpServletRequest request){
        ModelAndView modelAndView = new ModelAndView("member/posit/cash_list");
        PdCashSearchBean pdCash = new PdCashSearchBean();
        pdCash.setStart(page == null ? 1 : page);
        pdCash.setPageSize(Page.DEFAULT_PAGE_SIZE);
        pdCash.setMname(mname);
        pdCash.setBankUser(pdc_bank_user);
        pdCash.setStime(stime);
        pdCash.setEtime(etime);
        pdCash.setPayState(paystate_search);
        List<PdCashVo>  pdCashVos = pdCashMapper.selectByMember(pdCash);
        pdCash.setResultList(pdCashVos);
        modelAndView.addObject("modelPage", pdCash);
        return  modelAndView;
    }

    @RequestMapping("cashView")
    public ModelAndView cashView(Integer id){
        ModelAndView modelAndView = new ModelAndView("member/posit/cash_view");
        PdCash pdCash = pdCashMapper.selectByPrimaryKey(id);
        modelAndView.addObject("pdCash", pdCash);
        return  modelAndView;
    }
    @RequestMapping("cashEdit")
    public String cashEDit(Integer id,HttpServletRequest request){
        MemberBase memberBase = (MemberBase)request.getSession().getAttribute("memInfo");
        PdCash pdCash = new PdCash();
        pdCash.setPdcId(id);
        pdCash.setPdcPaymentState("1");
        pdCashMapper.updateByPrimaryKeySelective(pdCash);
        pdCash=pdCashMapper.selectByPrimaryKey(id);
        PdLog pdLog = new PdLog();
        pdLog.setLgMemberId(pdCash.getPdcMemberId());
        pdLog.setLgMemberName(pdCash.getPdcMemberName());
        pdLog.setLgAdminName(memberBase.getUserName());
        pdLog.setLgType("cash_pay");
        pdLog.setLgFreezeAmount(pdCash.getPdcAmount());
        pdLog.setLgAddTime(Integer.parseInt(DateUtil.unixTimeStamp()));
        pdLog.setLgDesc("");
        pdLogMapper.insertSelective(pdLog);
        Member mb = memberMapper.getMemberById(pdCash.getPdcMemberId());
        if(mb.getFreezePredeposit()!=null&&
                (mb.getFreezePredeposit().compareTo(pdCash.getPdcAmount())==1||
                        mb.getFreezePredeposit().compareTo(pdCash.getPdcAmount())==0)){
            mb.setFreezePredeposit(mb.getFreezePredeposit().subtract(pdCash.getPdcAmount()));
        }
        memberMapper.updateMemberBaseInfo(mb);
        return  "redirect:/member/positSetting/cashList";
    }
    @RequestMapping("cashDel")
    public String cashDel(Integer id,HttpServletRequest request){
        MemberBase memberBase = (MemberBase)request.getSession().getAttribute("memInfo");

        PdCash pdCash=pdCashMapper.selectByPrimaryKey(id);
        PdLog pdLog = new PdLog();
        pdLog.setLgMemberId(pdCash.getPdcMemberId());
        pdLog.setLgMemberName(pdCash.getPdcMemberName());
        pdLog.setLgAdminName(memberBase.getUserName());
        pdLog.setLgType("cash_del");
        pdLog.setLgAvAmount(pdCash.getPdcAmount());
        pdLog.setLgFreezeAmount(pdCash.getPdcAmount());
        pdLog.setLgAddTime(Integer.parseInt(DateUtil.unixTimeStamp()));
        pdLog.setLgDesc("");
        pdLogMapper.insertSelective(pdLog);
        Member mb = memberMapper.getMemberById(pdCash.getPdcMemberId());
        if(mb.getAvailablePredeposit()!=null){
            mb.setAvailablePredeposit(mb.getAvailablePredeposit().add(pdCash.getPdcAmount()));
        }else{
            mb.setAvailablePredeposit(pdCash.getPdcAmount());
        }
        if(mb.getFreezePredeposit() !=null&&
                (mb.getFreezePredeposit().compareTo(pdCash.getPdcAmount()) == 1 ||
                        mb.getFreezePredeposit().compareTo(pdCash.getPdcAmount())==0)){
            mb.setFreezePredeposit(mb.getFreezePredeposit().subtract(pdCash.getPdcAmount()));
        }
        memberMapper.updateMemberBaseInfo(mb);
        pdCashMapper.deleteByPrimaryKey(id);
        return  "redirect:/member/positSetting/cashList";
    }

    @RequestMapping("positSetting/logList")
    public ModelAndView logList(Integer page,Integer mid, String mname,String aname,String stime,String etime,HttpServletRequest request){
        ModelAndView modelAndView = new ModelAndView("member/posit/log_list");
        PdLogSearchBean pdLog = new PdLogSearchBean();
        pdLog.setStart(page == null ? 1 : page);
        pdLog.setPageSize(Page.DEFAULT_PAGE_SIZE);
        pdLog.setMemberId(mid);
        pdLog.setMname(mname);
        pdLog.setAname(aname);
        pdLog.setStime(stime);
        pdLog.setEtime(etime);
        List<PdLogVo>  pdLogVos = pdLogMapper.selectByCondition(pdLog);
        pdLog.setResultList(pdLogVos);
        modelAndView.addObject("modelPage", pdLog);
        return  modelAndView;
    }

    @AuthPassport
    @RequestMapping("points/pointsSetting")
    public ModelAndView pointsSetting(){
        ModelAndView modelAndView = new ModelAndView("member/points/points_setting");
        return modelAndView;
    }

    /**
     * 会员验证
     * @return
     */
    @RequestMapping("checkMember")
    public @ResponseBody Member checkMember(@RequestParam Integer memberId){
        Member member = new Member();
        member.setMemberId(memberId);
        member = memberService.getUcenterMemberById(memberId);
        return member;
    }

    /**
     * 会员存在CHECK
     * @param memberId
     * @return
     */
    @RequestMapping("checkMemberFalse")
    public @ResponseBody Boolean checkAdminName(@RequestParam Integer memberId) {
        Member member = new Member();
        member.setMemberId(memberId);
        member = memberService.getUcenterMemberById(memberId);
        if(member == null){
            return false;
        }else {
            return true;
        }
    }

    @AuthPassport
    @RequestMapping("/points/pointsEdit")
    public ModelAndView pointsEdit(HttpServletRequest request,Integer member_id,String member_name,
                                   Integer operatetype,Integer pointsnum,String pointsdesc){
        MemberBase memberBase = (MemberBase)request.getSession().getAttribute("memInfo");
        PointsLog pointsLog = new PointsLog();
        pointsLog.setPlMemberid(member_id);
        pointsLog.setPlMembername(member_name);
        Member member = memberService.findSimpleMemberById(member_id);
        if(operatetype==2) {
            pointsLog.setPlPoints(new BigDecimal(pointsnum).negate());
            member.setMemberPoints(member.getMemberPoints() - pointsnum);
        } else {
            pointsLog.setPlPoints(new BigDecimal(pointsnum));
            member.setMemberPoints(member.getMemberPoints() + pointsnum);
        }
        Integer updateMemberFlg = memberService.updateMemberBaseInfo(member);
        pointsLog.setPlDesc(pointsdesc);
        pointsLog.setPlAddtime(Integer.parseInt(DateUtil.unixTimeStamp()));
        pointsLog.setPlAdminid(memberBase.getUserId());
        pointsLog.setPlAdminname(memberBase.getUserName());
        pointsLog.setPlStage("system");
        Integer insertPointsLogFlg = pointsLogMapper.insert(pointsLog);

        ModelAndView modelAndView = new ModelAndView("msg");
        if (updateMemberFlg == 1 && insertPointsLogFlg == 1) {
            modelAndView.addObject("msg", "会员积分管理成功");
        } else {
            modelAndView.addObject("msg", "会员积分管理失败");
        }
        modelAndView.addObject("returnUrl", "member/points");
        return modelAndView;
    }



    @AuthPassport
    @RequestMapping("/points")
    public ModelAndView pointsList(HttpServletRequest request){
        ModelAndView modelAndView = new ModelAndView("member/points/points_list");
        //查询条件
        String mname = request.getParameter("mname");
        String stime = request.getParameter("stime");
        String etime = request.getParameter("etime");
        String aname = request.getParameter("aname");
        String stage = request.getParameter("stage");
        PointsLogSearchBean pointsLog = new PointsLogSearchBean();
        //改页处理用
        String start = request.getParameter("start");
        if (start != null && !"".equals(start)) {
            pointsLog.setStart(Integer.valueOf(start));
        }
        pointsLog.setPageSize(Page.DEFAULT_PAGE_SIZE);
        pointsLog.setPlMembername(mname);
        pointsLog.setStartTime(stime);
        pointsLog.setEndTime(etime);
        pointsLog.setPlAdminname(aname);
        pointsLog.setPlStage(stage);
        List<PointsLogVo> pointsLogs = pointsLogMapper.selectByMember(pointsLog);
        pointsLog.setResultList(pointsLogs);
        modelAndView.addObject("page", pointsLog);
        return modelAndView;
    }

    public MemberController() {
    }

    @RequestMapping(value = "memList")
    public ModelAndView memberList(HttpServletRequest request,Integer page,Integer member_type){
        ModelAndView res = new ModelAndView("member/list");
        //查询条件
        String searchFieldName = request.getParameter("search_field_name");
        String searchFieldValue = request.getParameter("search_field_value");
        MemberSearchBean memberSearch = new MemberSearchBean();
        //设置参数
        if(StringUtils.isNotEmpty(searchFieldValue)){
            if("truename".equals(searchFieldName)){
                memberSearch.setMemberTrueName("%"+searchFieldValue+"%");
            }
            if("name".equals(searchFieldName)){
                memberSearch.setMemberName("%"+searchFieldValue+"%");
            }
            if("recommend".equals(searchFieldName)){
                memberSearch.setRecommendName("%"+searchFieldValue+"%");
            }
        }
        //改页处理用
        String start = request.getParameter("start");
        if (start != null && !"".equals(start)) {
            memberSearch.setStart(Integer.valueOf(start));
        }
        memberSearch.setPageSize(10);
        Page<Member> memberPage = memberService.getMemberListForAdmin(memberSearch);
        memberSearch.setResultList(memberPage.getResultList());
        res.addObject("page",memberSearch);
        res.addObject("search_field_name",searchFieldName);
        res.addObject("search_field_value",searchFieldValue);
        return res;
    }

    @RequestMapping(value = "memList/toEmpLevel")
    public ModelAndView setEmpLevel(Integer memberId){
        ModelAndView res = new ModelAndView("member/level/empLevel");
        // 会员信息的取得
        MemberWithBLOBs memberInfo = memberMapper.selectByPrimaryKey(memberId);
        res.addObject("member",memberInfo);

        // 员工级别的取得
        EnumParam enumParam = new EnumParam();
        enumParam.setPageSwitch(false);
        enumParam.setParamType("employee_Level");
        enumParam.setParamState(1);
        List<EnumParam> list = enumParamMapper.selectListByCondition(enumParam);
        res.addObject("empLevels", list);

        return res;
    }
    /**
     * 员工等级更新
     * @return
     */
    @RequestMapping("memList/doEmpLevel")
    public ModelAndView EmpLevelUpdate(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("msg");

        String memberId = request.getParameter("memberId");
        String empLevel = request.getParameter("empLevel");
        // V1 -->> 1
        Integer employeeLevel = Integer.valueOf(empLevel.substring(1));

        MemberWithBLOBs member = new MemberWithBLOBs();
        member.setMemberId(Integer.valueOf(memberId));
        member.setEmployeeLevel(employeeLevel);
        Integer updateMemberFlg = memberMapper.updateByPrimaryKeySelective(member);

        if (updateMemberFlg == 1) {
            modelAndView.addObject("msg", "员工级别设置成功");
        } else {
            modelAndView.addObject("msg", "员工级别设置失败");
        }
        modelAndView.addObject("returnUrl", "member/memList");
        return modelAndView;
    }

    @RequestMapping(value = "memList/edit",method = RequestMethod.GET)
    public ModelAndView edit(@RequestParam Integer memberId){
        ModelAndView res = new ModelAndView("member/edit");

        return res;
    }

    @RequestMapping(value = "memList/add",method = RequestMethod.GET)
    public ModelAndView add(){
        ModelAndView res = new ModelAndView("member/add","member",new Member());
        return res;
    }

    /**
     * 设置为会员
     * @param memberIds
     * @param level
     * @return
     */
    @AuthPassport
    @RequestMapping(value = "setEmployee",method = RequestMethod.POST)
    public String setEmployee(HttpSession session,@RequestParam String memberIds,@RequestParam String memberNames,@RequestParam Integer level){
        MemberBase adminInfo = (MemberBase)session.getAttribute("memInfo");
        String[] ids = memberIds.split(",");
        String[] names = memberNames.split(",");

        for(int i=0;i<ids.length;i++){
            Employee employee = new Employee();
            employee.setEmpMemberid(Integer.parseInt(ids[i]));
            employee.setEmpMembername(names[i]);
            employee.setEmpLevel(level.byteValue());
            employee.setEmpAddtime(DateUtil.unixTimeStampInt().intValue());
            employee.setEmpState(true);

            employeeService.updateMemberToEmploy(employee);
        }
        return "redirect:memList";
    }

    /**
     * 验证旧密码
     * @return
     */
    @RequestMapping("checkPwd")
    public @ResponseBody boolean checkPwd(String old_pw,HttpSession session) {
        Member member = memberService.getBaseMemberInfo(((MemberBase) session.getAttribute("memInfo")).getUserName());
        String oldPwd = DigestUtils.md5Hex(old_pw);
        if (oldPwd.equals(member.getMemberPasswd())) {
            return true;
        } else {
            return false;
        }
    }
    /**
     * 会员等级更新
     * @return
     */
    @RequestMapping("memLevel/update")
    public ModelAndView levelUpdate(HttpServletRequest request) {
        ModelAndView modelAndView = new ModelAndView("msg");
        int loopCount = 0;
        Integer result = 0;
        Enumeration<String> enums = request.getParameterNames();
        while (enums.hasMoreElements()) {
            String name = enums.nextElement();    //获取属性的名字
            String value = request.getParameter(name);
            if (org.apache.commons.lang.StringUtils.isNotEmpty(value) && value != "") {
                loopCount++;
                Setting set = new Setting();
                set.setName(name);
                set.setValue(value);
                Integer updateResult = settingService.updateSetting(set);
                if (updateResult == 1) {
                    result++;
                }
            }
//            modelAndView.addObject( name+"_value", settingService.getSettingInfo(SettingNameEnum.getSettingNameEnum(name)));
        }
        if (loopCount == result) {
            modelAndView.addObject("msg", "会员级别设置成功");
        } else {
            modelAndView.addObject("msg", "会员级别设置失败");
        }
        modelAndView.addObject("returnUrl", "member/memLevel");
        return modelAndView;
    }

    /**
     * 会员等级
     * @return
     */
    @RequestMapping("memLevel")
    public ModelAndView setSettlement(){
        ModelAndView modelAndView = new ModelAndView("member/level/levelList");
        try {
            modelAndView.addObject("member_level_zero_value",settingService.getSettingInfo(SettingNameEnum.MEMBER_LEVEL_ZERO));
            modelAndView.addObject("member_level_one_value",settingService.getSettingInfo(SettingNameEnum.MEMBER_LEVEL_ONE));
            modelAndView.addObject("member_level_two_value",settingService.getSettingInfo(SettingNameEnum.MEMBER_LEVEL_TWO));
            modelAndView.addObject("member_level_three_value",settingService.getSettingInfo(SettingNameEnum.MEMBER_LEVEL_THREE));
            modelAndView.addObject("member_level_four_value",settingService.getSettingInfo(SettingNameEnum.MEMBER_LEVEL_FOUR));
            modelAndView.addObject("member_level_five_value",settingService.getSettingInfo(SettingNameEnum.MEMBER_LEVEL_FIVE));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return modelAndView;

    }

    @RequestMapping(value = "notice")
    public ModelAndView notice(Integer memberId){
        ModelAndView res = new ModelAndView("member/notice/notice");
        String memberName = "";
        MemberWithBLOBs memberInfo = memberMapper.selectByPrimaryKey(memberId);
        if (memberInfo != null) {
            memberName = memberInfo.getMemberName();
        }
        res.addObject("memberName",memberName);
        return res;
    }

    @RequestMapping(value = "notice/noticeSend")
    @AuthPassport
    public ModelAndView notice(String userName,String sendType,String messageBody,HttpServletRequest request){
        MemberBase memberBase = (MemberBase)request.getSession().getAttribute("memInfo");
        String errMemberName = "";
        if(sendType.equals("1")){
            for(String uname:userName.split(",|，")){
                Member member = memberService.getBaseMemberInfo(uname);
                if (member == null) {
                    if (errMemberName.length() > 0) {
                        errMemberName = errMemberName.concat("," + uname);
                    } else {
                        errMemberName = errMemberName.concat(uname);
                    }
                } else {
                    Message message = new Message();
                    message.setMessageBody(messageBody);
                    message.setMessageOpen(0);
                    message.setMessageState(0);
                    message.setMessageParentId(0);
                    message.setMessageIsmore(0);
                    message.setMessageType(1);//0为私信、1为系统消息、2为留言
                    message.setFromMemberId(memberBase.getUserId());
                    message.setFromMemberName("admin");
                    message.setToMemberId(member.getMemberId().toString());
                    message.setToMemberName(member.getMemberName());
                    message.setMessageTime(DateUtil.unixTimeStampInt().intValue());
                    messageService.insertMessage(message);
                }
            }
        }else if(sendType.equals("2")) {
            List<Member> members = memberService.getMemberByCond(new Member());
            for(Member member:members){
                Message message = new Message();
                message.setMessageParentId(0);
                message.setMessageOpen(0);
                message.setMessageState(0);
                message.setMessageIsmore(0);
                message.setMessageBody(messageBody);
                message.setMessageType(1);//0为私信、1为系统消息、2为留言
                message.setFromMemberId(memberBase.getUserId());
                message.setFromMemberName("admin");
                message.setToMemberId(member.getMemberId().toString());
                message.setToMemberName(member.getMemberName());
                message.setMessageTime(DateUtil.unixTimeStampInt().intValue());
                messageService.insertMessage(message);
            }
        }
        ModelAndView modelAndView = new ModelAndView("msg");
        if (errMemberName.length() > 0) {
            modelAndView.addObject("msg", "以下会员通知发送失败：" + errMemberName);
        } else {
            modelAndView.addObject("msg", "会员通知发送成功");
        }
        modelAndView.addObject("returnUrl", "member/notice");
        return modelAndView;
    }

}
